/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import java.util.ArrayList;
import java.util.Date;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


/**
 *
 * @author konsta
 */
@Stateless
public class InsuranceFacade extends AbstractFacade<Insurance> {

   
    @PersistenceContext(unitName = "team_project-ejbPU")
    private EntityManager em;
    
    private Client client = new Client();


    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public InsuranceFacade() {
        super(Insurance.class);
    }

   
    public ArrayList<String> Insurance_information() {

        ArrayList<String> temp = new ArrayList<String>();
        int i;

        for (i = 1; i < 6; i++) {
            for (Insurance insure : findAll()) {
                if (insure.getInsurancetype() == i) {
                    temp.add("insurance name : "+ insure.getName());
                    temp.add("insurance fee : "+Double.toString(insure.getFee()));
                    temp.add("insurance duration : "+insure.getDuration());
                    temp.add("insurance description : "+insure.getDescription());

                }
            }
        }

        return temp;

    }

    
    public ArrayList<String> private_by_insurance(String str) {

        
        ArrayList<String> temp = new ArrayList<String>();
        
        for (Insurance ins : findAll()) {
            if(Integer.toString(ins.getInsurancetype())==str){
                temp.add(Integer.toString(ins.getInsurancetype()));
                //temp.add(Interger.toString(ins.getDuration()));
                temp.add(ins.getDescription());
                temp.add(Double.toString(ins.getFee()));
               
                
                return temp;
            
            }
            
        
    }

         return null ;
  
    }
    
    @Override
    public String toString(){
        
        
        
        return null;
    }
    
    
    
    
}
